import { createRouter, createWebHashHistory } from 'vue-router'
import UserManageRouter from './modules/UserManage'
import RoleListRouter from './modules/RoleList'
import PermissionListRouter from './modules/PermissionList'
import ArticleRouter from './modules/Article'
import ArticleCreateRouter from './modules/ArticleCreate'
import ConfigManage from './modules/ConfigManage'
import DataDashboard from './modules/DataDashboard'
import layout from '@/layout/index.vue'
/**
 * 私有路由表
 */
export const privateRoutes = [
  UserManageRouter,
  RoleListRouter,
  PermissionListRouter,
  ArticleRouter,
  ArticleCreateRouter,
  ConfigManage,
  DataDashboard
]

/**
 * 公开路由表
 */
const publicRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/',
    // 注意：带有路径“/”的记录中的组件“默认”是一个不返回 Promise 的函数
    component: layout,
    redirect: '/ai-pricing',
    children: [
      {
        path: '/ai-pricing',
        name: 'aiPricing',
        component: () => import('@/views/ai-pricing/index.vue'),
        meta: {
          title: 'aiPricing',
          icon: 'aiPricing'
        }
      },
      // {
      //   path: '/chart',
      //   name: 'chart',
      //   component: () => import('@/views/chart/index.vue'),
      //   meta: {
      //     title: 'chart',
      //     icon: 'chart'
      //   }
      // },
    ]
  },
  // {
  //   path: '/components',
  //   // 注意：带有路径“/”的记录中的组件“默认”是一个不返回 Promise 的函数
  //   component: layout,
  //   redirect: '/components/video',
  //   name: 'video',
  //   meta: { title: 'components', icon: 'components' },
  //   children: [
  //     {
  //       path: '/components/video',
  //       component: () => import('@/views/video/index.vue'),
  //       meta: {
  //         title: 'video',
  //         icon: 'video'
  //       }
  //     },
  //     {
  //       path: '/components/numberAnimate',
  //       component: () => import('@/views/numberAnimate/index.vue'),
  //       meta: {
  //         title: 'numberAnimate',
  //         icon: 'numberAnimate'
  //       }
  //     }
  //   ]
  // },
  {
    path: '/:pathMatch(.*)',
    component: () => import('@/views/not-found/index.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: [...publicRoutes],
  scrollBehavior(to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 }
  }
})

export default router
